home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / tex-k / tex-eplain-archive / 000028_dorai@ses.com_Tue Aug 30 06:59:04 1994.msg < prev    next >
Internet Message Format  |  1995-01-08  |  3KB

  1. Received: from uu10.psi.com by cs.umb.edu with SMTP id AA25172
  2.   (5.65c/IDA-1.4.4 for <tex-eplain@cs.umb.edu>); Tue, 30 Aug 1994 12:59:20 -0400
  3. Received: from mario.ses.com by uu10.psi.com (5.65b/4.0.061193-PSI/PSINet) via SMTP;
  4.         id AA02897 for tex-eplain@cs.umb.edu; Tue, 30 Aug 94 13:02:01 -0400
  5. Date: Tue, 30 Aug 94 11:59:04 CDT
  6. From: dorai@ses.com (Dorai Sitaram)
  7. Received: from frodo.ses.com (frodo.ARPA) by ses.com (4.1/3.1.012693-SES - Scientific and Engineering Software);
  8.         id AA24782 for tex-eplain@cs.umb.edu; Tue, 30 Aug 94 11:59:04 CDT
  9. Message-Id: <9408301659.AA24782@ses.com>
  10. To: tex-eplain@cs.umb.edu
  11. Subject: Copying from TeX source verbatim to a file
  12.  
  13.  
  14. We all know that TeX allows writing stuff during the
  15. course of TeXing to a temp file, e.g., eplain's code
  16. for managing tocs and indexes.  I suggest that a
  17. generalized macro for copying portions of a TeX source
  18. file verbatim to another file (whether .doc, .mf or
  19. another .tex file) can be a nice addition to eplain.  I
  20. just downloaded Zdenek Wagner's drawing.tex, and found
  21. that he uses this tactic to copy stuff from his main
  22. file into an .mf file.  To do this, he uses the old
  23. Mainz verbatim.sty that gives him some programmable
  24. hooks, and while I understand what it does, I don't
  25. really know how it does it. 
  26.  
  27. I found this strategy of using TeX to write stuff into
  28. other files in other places too, e.g., the old Mainz
  29. distribution's docstrip utility which is rather too
  30. complex for our purposes, and a much simpler file
  31. called wrtfile.tex by Cameron Smith that does something
  32. similar for plain TeX.  Here's a very simple macro with
  33. just the barebones transcripting ability.  It follows
  34. Cameron Smith but doesn't have any of the extra
  35. features that he provides.
  36.  
  37. Usage:
  38.  
  39. \transcript <filename>
  40. ...
  41. <arbitrary ascii stuff>
  42. ...
  43. endtranscript
  44.  
  45. This will copy the <arbitrary ascii stuff> verbatim to
  46. the file <filename>.  You can change the string that
  47. signals end of transcript by redefining \endtranscript.
  48. Initially, \def\endtranscript{endtranscript}.
  49.  
  50. Code follows.  Please ignore if this is old hat.
  51.  
  52. --d
  53.  
  54. % trnscrpt.tex
  55.  
  56. \begingroup
  57. \catcode`\^^M=12%
  58. % the following %'s are necessary --- don't remove!
  59. \gdef\transcript #1 {\begingroup%
  60. \immediate\openout0=#1\relax
  61. \def\do##1{\catcode`##1=12\relax}\dospecials%
  62. \catcode`\^^M=12\relax%
  63. \transcriptreadline}%
  64. %
  65. \gdef\transcriptreadline#1^^M{%
  66. \def\transcriptreadlinearg{#1}%
  67. \ifx\transcriptreadlinearg\endtranscript%
  68. \def\next{\immediate\closeout0\endgroup}\else%
  69. \def\next{\immediate\write0{#1}\transcriptreadline}\fi%
  70. \next}%
  71. \endgroup
  72.  
  73. \def\endtranscript{endtranscript}
  74.  
  75. % end of file